<%@page import="com.javandad.app.server.UserManager"%>
<%@page import="com.javandad.app.server.db.DatabaseManager" %>
<%@page import="javax.jdo.PersistenceManager" %>
<%@page import="com.javandad.app.server.db.PMFSingleton" %>
<%@page import="com.javandad.app.shared.entity.User"  %>

<%
	PersistenceManager pm = PMFSingleton.getPM();
	User user = UserManager.getCurrentUser(pm);
	String codesvrParam = request.getParameter("gwt.codesvr");
	if(codesvrParam != null && !codesvrParam.equals(""))
		codesvrParam = "gwt.codesvr="+codesvrParam;
	if(user != null)
	{
		if (user.getUsername() != null) {
			String mode = "1";
			session.setAttribute("mode", mode);
			session.setAttribute("username", user.getUsername());
			session.setAttribute("user", user);
			String redirectURL = "home.jsp?"+codesvrParam;
			response.sendRedirect(redirectURL);
		} else {
			response.sendRedirect("Register.jsp?"+codesvrParam);
		}
	}
	else
	{
		session.removeAttribute("username");
		session.removeAttribute("user");
		session.removeAttribute("mode");
	}
%>

<jsp:include page="welcome.jsp" >
<jsp:param value="<%= codesvrParam %>" name="codesvrParam"/>
</jsp:include> 
